API Quick Start

Generate PDF documents with our REST API

Authenticate With

Your API Key

DocuGenerate provides secure access to its API through the use of API Keys, which allow developers to access and integrate the DocuGenerate platform into their own applications.

You can get your API Key from the Settings page. To authenticate, the API Key needs to be included in all API requests to the server via the header Authorization: <API Key>

DocuGenerate API key sent in the Authorization header of an API request
Template Resource

Create A Template

Templates are the building blocks of DocuGenerate, providing a way to generate high-quality documents with consistent formatting. With templates, you can define the structure of your documents once and then use them repeatedly to generate new documents as needed.

To create a new template, you need to send a POST request to https://api.docugenerate.com/v1/template with the file parameter referencing the template file. Make sure to use multipart/form-data as the content type when making the request.

DocuGenerate will respond with a JSON object containing the template's properties, including for example the list of detected tags.

curl -X 'POST' \
  'https://api.docugenerate.com/v1/template' \
  -H 'Accept: application/json' \
  -H 'Authorization: 491c000c5fad32ed7787005b0723ad55' \
  -H 'Content-Type: multipart/form-data' \
  -F 'file=@Business Letter.docx;type=application/vnd.openxmlformats-officedocument.wordprocessingml.document' \
  -F 'name=' \
  -F 'delimiters={
  "left": "[",
  "right": "]"
}' \
  -F 'region=us' \
  -F 'enhanced_syntax=false' \
  -F 'versioning_enabled=true'

{
  "enhanced_syntax": false,
  "versioning_enabled": true,
  "tags": {
    "valid": [
      "Date",
      "Name",
      "Job Title",
      "Company Name",
      "Street Address",
      "City",
      "State",
      "Zip Code",
      "Email",
      "Phone"
    ],
    "invalid": []
  },
  "created": 1748863881127,
  "updated": 1748863881127,
  "name": "Business Letter",
  "delimiters": {
    "left": "[",
    "right": "]"
  },
  "filename": "Business Letter.docx",
  "format": ".docx",
  "region": "us",
  "page_count": 1,
  "image_uri": "https://firebasestorage.googleapis.com/v0/b/storage.us.docugenerate.com/o/templates%2Fbet2oQirk0pSd9ctH9Qu%2FBusiness%20Letter.png?alt=media&token=d534d7f0-ccb6-4d6d-a9cf-7ffa55e82b95",
  "preview_uri": "https://firebasestorage.googleapis.com/v0/b/storage.us.docugenerate.com/o/templates%2Fbet2oQirk0pSd9ctH9Qu%2FBusiness%20Letter.pdf?alt=media&token=8f60f256-c454-4ffc-a8da-670431a62e82",
  "template_uri": "https://firebasestorage.googleapis.com/v0/b/storage.us.docugenerate.com/o/templates%2Fbet2oQirk0pSd9ctH9Qu%2FBusiness%20Letter.docx?alt=media&token=0904bdf4-6046-4c03-a612-ebdf145fdee5",
  "id": "bet2oQirk0pSd9ctH9Qu"
}
Document Resource

Generate Documents

You generate documents by sending a POST request to https://api.docugenerate.com/v1/document with the template_id and data parameters. Either the multipart/form-data or application/json content type can be used.

The data parameter should be a JSON object with values for merging into the template. A document will be generated by replacing the template's merge tags with the object's values. Each key from the object needs to exactly match the name of a tag in the template, including spaces and capitalization.

{
  "Name": "Emily Carter",
  "Job Title": "Operations Manager",
  "Company Name": "Harbor Point Consulting",
  "Street Address": "118 West Street",
  "City": "Annapolis",
  "State": "Maryland",
  "Zip Code": "21405",
  "Email": "emily.carter@example.com",
  "Phone": "(410) 555-0142"
}

curl -X 'POST' \
  'https://api.docugenerate.com/v1/document' \
  -H 'Accept: application/json' \
  -H 'Authorization: 491c000c5fad32ed7787005b0723ad55' \
  -H 'Content-Type: multipart/form-data' \
  -F 'template_id=bet2oQirk0pSd9ctH9Qu' \
  -F 'output_quality=100' \
  -F 'attach=' \
  -F 'output_name=' \
  -F 'data={ "Name": "Emily Carter", "Job Title": "Operations Manager", "Company Name": "Harbor Point Consulting", "Street Address": "118 West Street", "City": "Annapolis", "State": "Maryland", "Zip Code": "21405", "Email": "emily.carter@example.com", "Phone": "(410) 555-0142" }' \
  -F 'name=' \
  -F 'merge_with=' \
  -F 'page_break=true' \
  -F 'single_file=true' \
  -F 'output_format=.pdf'

DocuGenerate will respond with a JSON object containing the document's properties, including document_uri that points to the URL of the generated document. The output_format of the generated document can be .docx, .pdf, .doc, .odt or .txt.

{
  "created": 1791125416372,
  "template_id": "bet2oQirk0pSd9ctH9Qu",
  "name": "Business Letter",
  "format": ".pdf",
  "data_length": 1,
  "filename": "Business Letter.pdf",
  "document_uri": "https://firebasestorage.googleapis.com/v0/b/storage.us.docugenerate.com/o/documents%2FiESelthRt4uaYQRTemrL%2FBusiness%20Letter.pdf?alt=media&token=c4b259ec-249b-4b35-a62f-6a8dc0da75f3",
  "id": "iESelthRt4uaYQRTemrL"
}

The DocuGenerate API works with any programming language that can send HTTP requests. Our detailed guides include step-by-step instructions for Node.js, Python, PHP, Ruby, Go, C#, Rust and Java, with ready-to-use code examples for every API method.

Each guide covers the full workflow, from uploading a template to generating and downloading documents. Browse all languages on the dedicated API SDKs page and start generating documents from your applications in just a few minutes.

DocuGenerate API SDKs for Node.js, Python, PHP, Ruby, Go, C#, Rust and Java
API Reference

Next Steps

You can find a complete list of all available endpoints, including information about the request body parameters and the response schemas, on the API Reference page.

These endpoints are the foundation of the DocuGenerate platform, providing a comprehensive set of tools for managing templates and documents. By leveraging these resources, you can easily build robust document generation workflows that can be customized to meet the specific needs of your organization.

In case you have any questions about using DocuGenerate's API, you'll find a wealth of useful resources in our API Help Center.

The 10 DocuGenerate API endpoints for managing templates and documents
Sign Up

Start Generating PDFs With Our API

Get started with 20 free documents per month and make your first API call in minutes.

Start Generating for Free
  • Full API access on the Free plan
  • No credit card required